<template>
  <div>
    <van-cell-group>
 <van-field v-model="user.phone" type="tel" label="手机号" />
 <van-field v-model="user.nickname" label="昵称" />
 <van-field v-model="user.password" type="password" label="密码" />
</van-cell-group>
  <van-button
      style="margin-top: 30px"
      class="input"
      round
      type="info"
      size="normal"
      color="pink"
      @click="register"
      >注册</van-button
    >
     <van-button
      style="margin-top: 30px"
      class="input"
      round
      type="info"
      size="normal"
      color="pink"
      @click="$router.push('/login')"
      > 前往登录</van-button
    >
    <!-- <div class="input">
      <div>
        手机号111：<input type="text" v-model="user.phone" />{{ user.phone }}
      </div>
      <div>
        昵称：<input type="text" v-model="user.nickname" />{{ user.nickname }}
      </div>
      <div>
        密码：<input type="text" v-model="user.password" />{{ user.password }}
      </div>
      <button @click="register">注册</button>
      
    </div> -->
  </div>
</template>
<script>
import  {reregister} from "../../http/http";
import { Toast } from "vant";
export default {
  data() {
    return {
      user: {
        phone: "",
        nickname: "",
        password: "",
      },
    };
  },
  methods: {
    register() {
      console.log(1);
      reregister(this.user).then((res) => {
        console.log(res);
        if (res.data.code === 200) {
          this.$router.push("/login");
        } else {
         Toast({
            message: res.data.msg,
            position: "top",
          });
        }
      });
    },
  },
};
</script>
<style scoped>
.input {
  width: 100%;
  text-align: center;
}
input {
  margin: 10px auto;
}
</style>